<style>
    .form-signin {
        max-width: 330px;
        padding: 15px;
        margin: 0 auto;
    }
    .form-signin .form-signin-heading,
    .form-signin .checkbox {
        margin-bottom: 10px;
    }
    .form-signin .checkbox {
        font-weight: normal;
    }
    .form-signin .form-control {
        position: relative;
        height: auto;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        padding: 10px;
        font-size: 16px;
    }
    .form-signin .form-control:focus {
        z-index: 2;
    }
    .form-signin input[type="email"] {
        margin-bottom: -1px;
        border-bottom-right-radius: 0;
        border-bottom-left-radius: 0;
    }
    .form-signin input[type="password"] {
        margin-bottom: 10px;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
</style>
<?php
//$reqs = Blyn::app()->getActiveSpace()->getSpaceEngine()->getWXJoinSpaceRequests();
//$joinedUsers = Blyn::app()->getActiveSpace()->getSpaceEngine()->getJoinedSpaceRoles();
//$space = Blyn::app()->getActiveSpace();

if ($joinedUsers != NULL && is_array($joinedUsers)) {
    if($current_index == NULL)
        $current_index = 0;
    
    $index = 0;
    foreach ($joinedUsers as $reqId => $request)     
    {
        if($current_index == $index) {
        $sender_user = new BUser($request['userId']);
        $sender_Space = new BSpace($request['spaceId']);
        $sender_sApp = Yii::t('site', BApp::getAppById($request['appId'])->name);
        $requestItem = array('messageId'=>$reqId, 'roleId'=>$request['roleId'], 'userId'=>$request['userId'] );
        break;
        }
        $index++;
    }
    $model = new BDynamicFormModel();
    $roleField = 'media_roleId_membership';
    $model->addField($roleField);
}


?>

<div class="container">
    <?php
//    if ($joinedUsers != NULL) 
    $form = $this->beginWidget('CActiveForm', array(
        "id" => "manage-myInfo-form",
        'enableAjaxValidation' => FALSE,
        'htmlOptions' => array('class' => 'form-signin', 'role' => 'form'),
    ));
    ?>
    <legend><h3 class="form-signin-heading text-muted">成员删除</h3></legend>

    <div class="displayUserInfo">
        <?php
        if (isset($applyResult)) {
            if ($applyResult == 'deleted') {
                ?>
                <p class="bg-warning">
                    <strong>用户: <?php echo $userName; ?> 成功删除.</strong>
                </p>
                <?php
            } 
        }
        ?>
        <?php if ($joinedUsers != NULL) {?>
        <h5>用户：</h5>
        <?php echo $sender_user->getName(); ?>
        <h5>角色：</h5>
        <?php echo Yii::t('site', $request['applyingRole']); ?>
        <?php
        echo $control->getAjaxLink(array('name' => '删除成员', 'id' => BUIMembership::Delete_Apply), array('reqId' => $requestItem, 'htmlOptions' => array(
                'class' => 'btn btn-success btn-lg btn-block'
        )));
        ?>        
        <?php
        if($current_index>0)
            echo $control->getAjaxLink(array('name' => '上一个', 'id' => 'previousSpaceUser'), array('joinedUsers' => $joinedUsers, 
                'current_index' => $current_index-1, 'htmlOptions' => array(
                    'class' => 'btn btn-warning btn-lg btn-block'
            )));
        if($current_index+1<count($joinedUsers))
            echo $control->getAjaxLink(array('name' => '下一个', 'id' => 'nextSpaceUser'), array('joinedUsers' => $joinedUsers, 
                'current_index' => $current_index+1, 'htmlOptions' => array(
                    'class' => 'btn btn-warning btn-lg btn-block'
            )));       
        }
        else
            echo "暂无成员."
        ?> 
    </div>
    <?php // if ($joinedUsers != NULL) 
        $this->endWidget(); ?>
</div>
